from abc import ABC, abstractmethod
from typing import Dict, Any


class BasicCard(ABC):
    """所有卡牌的基础类"""
    
    def __init__(self, card_id: str, name: str, image_path: str, description: str):
        self.card_id = card_id
        self.instance_id = None  # 实例唯一ID，将在召唤时设置
        self.name = name
        self.image_path = image_path
        self.description = description
    
    def to_dict(self) -> Dict[str, Any]:
        """将卡牌序列化为字典"""
        return {
            "card_id": self.card_id,
            "instance_id": self.instance_id,
            "name": self.name,
            "image_path": self.image_path,
            "description": self.description,
            "type": self.__class__.__name__
        }
    
    def __str__(self):
        return f"{self.name} ({self.card_id})"
    
    def __repr__(self):
        return f"{self.__class__.__name__}({self.card_id})"
